﻿// Copyright (c) Aura development team - Licensed under GNU GPL
// For more information, see license file in the main folder

using Aura.Channel.World.Entities.Creatures;
using Aura.Mabi.Network;

namespace Aura.Channel.Network.Sending.Helpers
{
	public static class ConditionHelper
	{
		public static Packet AddConditions(this Packet packet, CreatureConditions conditions)
		{
			// [?, NA? (20??-?-?)] Condition structure changed from multiple bitmasks to a list

			var activeConditions = conditions.GetActiveConditions();

			packet.PutInt(activeConditions.Count);
			foreach (var condition in activeConditions)
				packet.AddCondition(condition);

			packet.PutLong(0);

			return packet;
		}

		public static Packet AddCondition(this Packet packet, CreatureCondition condition)
		{
			packet.PutInt(condition.Id);
			packet.PutLong(-1);
			packet.PutString(condition.Extra.ToString());
			packet.PutLong(0);
			packet.PutString("");
			packet.PutString("");

			return packet;
		}
	}
}
